var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, o) {
    var a, i = arguments.length, s = i < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, n, o); else for (var r = t.length - 1; 0 <= r; r--) (a = t[r]) && (s = (i < 3 ? a(s) : 3 < i ? a(e, n, s) : a(e, n)) || s);
    return 3 < i && s && Object.defineProperty(e, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("MyScrollView"), s = e("SkinItemView"), c = e("HpView"), l = e("AudioManager"), d = e("SkinView"), u = e("PersonView"), p = e("GameData"), h = e("RoleManager"), f = e("WebManager"), g = cc._decorator, m = g.ccclass, y = g.property, v = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.changeBtn = null, t.personView = null, t.atkLabel = null, t.speLabel = null, 
        t.ranLabel = null, t.criLabel = null, t.movLabel = null, t.numLabel = null, t.up = null, 
        t.down = null, t.rankLabel = null, t.hpView = null, t.nums = [], t.ups = [], t.downs = [], 
        t.numPool = new cc.NodePool(), t.upPool = new cc.NodePool(), t.downPool = new cc.NodePool(), 
        t.idx = 0, t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        this.idx = p.GD.gunIdx, this.refresh(this.idx);
    }, t.prototype.onEnable = function() {
        var t = this;
        this.personView.init(p.GD.personIdx, this.idx, p.GD.backEquipIdx, p.GD.headEquipIdx, function() {
            t.show(t.idx);
        }), cc.systemEvent.emit("refresh_person_skin");
    }, t.prototype.onDisable = function() {
        this.removeAll();
    }, t.prototype.onClickChange = function() {
        l.default.getInstance().playAudio("按钮2"), f.default.getInstance().sentLog("点击皮肤界面更换武器按键"), 
        p.GD.gunIdx != this.idx && (p.GD.gunIdx = this.idx, this.refresh(p.GD.gunIdx), this.changeBtn.interactable = !1, 
        this.removeAll(), cc.systemEvent.emit("change_gun_skin"));
    }, t.prototype.onToggle = function(t) {
        t = t.getComponent(s.default).data.rank;
        (3e3 <= t || t <= p.GD.topRank) && this.show(t), cc.systemEvent.emit("toggle_gun_skin", t);
    }, t.prototype.start = function() {
        this.rankLabel.string = (p.GD.topRank + 1).toString();
    }, t.prototype.refresh = function(t) {
        this.idx = t, this.refreshBtn(t), this.refreshSkin(t), this.setValue(this.getValue(t, p.GD.personIdx)), 
        this.refreshLabel();
    }, t.prototype.show = function(t) {
        this.idx = t, this.refreshBtn(t), this.refreshSkin(t), this.removeAll(), this.showLabel(this.getValue(t, p.GD.personIdx));
    }, t.prototype.setValue = function(t) {
        h.default.getInstance().value = t;
    }, t.prototype.getValue = function(t, e) {
        var n = h.default.getInstance().getAtk(t, e), o = 10 * Math.floor(10 / h.default.getInstance().getSpe(t, e)), a = h.default.getInstance().getRan(t), i = h.default.getInstance().getCri(t, e), s = h.default.getInstance().getMove(t, e), e = h.default.getInstance().getHp(t, e);
        return new d.SkinItemValue(n, o, a, i, s, e);
    }, t.prototype.refreshLabel = function(t) {
        void 0 === t && (t = h.default.getInstance().value), this.atkLabel.string = t.atk.toString(), 
        this.speLabel.string = t.spe.toString(), this.ranLabel.string = t.ran.toString(), 
        this.criLabel.string = t.cri + "%", this.movLabel.string = t.mov.toString(), this.hpView.init(t.hp);
    }, t.prototype.showLabel = function(t) {
        void 0 === t && (t = h.default.getInstance().value), this.refreshLabel(t), t.atk != h.default.getInstance().value.atk && this.append(t.atk - h.default.getInstance().value.atk, this.atkLabel.node.parent), 
        t.spe != h.default.getInstance().value.spe && this.append(t.spe - h.default.getInstance().value.spe, this.speLabel.node.parent), 
        t.ran != h.default.getInstance().value.ran && this.append(t.ran - h.default.getInstance().value.ran, this.ranLabel.node.parent), 
        t.cri != h.default.getInstance().value.cri && this.append(t.cri - h.default.getInstance().value.cri, this.criLabel.node.parent), 
        t.mov != h.default.getInstance().value.mov && this.append(t.mov - h.default.getInstance().value.mov, this.movLabel.node.parent);
    }, t.prototype.refreshBtn = function(t) {
        t == p.GD.gunIdx ? this.changeBtn.interactable = !1 : this.changeBtn.interactable = !0;
    }, t.prototype.refreshSkin = function(t) {
        this.personView.changeGun(t), cc.systemEvent.emit("refresh_gun_skin");
    }, t.prototype.append = function(t, e) {
        var n, o = this.getNum();
        o.parent = e, o.setPosition(cc.v2(200, 0)), this.nums.push(o), 0 < t ? (o.color = cc.Color.GREEN, 
        o.getComponent(cc.Label).string = "+" + t, (n = this.getUp()).parent = e, n.setPosition(cc.v2(250, 0)), 
        this.ups.push(n)) : (o.color = cc.Color.RED, o.getComponent(cc.Label).string = "" + t, 
        (t = this.getDown()).setPosition(cc.v2(250, 0)), t.parent = e, this.downs.push(t));
    }, t.prototype.removeAll = function() {
        for (;0 < this.nums.length; ) this.numPool.put(this.nums.pop());
        for (;0 < this.ups.length; ) this.upPool.put(this.ups.pop());
        for (;0 < this.downs.length; ) this.downPool.put(this.downs.pop());
    }, t.prototype.getNum = function() {
        return 0 < this.numPool.size() ? this.numPool.get() : cc.instantiate(this.numLabel.node);
    }, t.prototype.getUp = function() {
        return 0 < this.upPool.size() ? this.upPool.get() : cc.instantiate(this.up);
    }, t.prototype.getDown = function() {
        return 0 < this.downPool.size() ? this.downPool.get() : cc.instantiate(this.down);
    }, a([ y(cc.Button) ], t.prototype, "changeBtn", void 0), a([ y(u.default) ], t.prototype, "personView", void 0), 
    a([ y(cc.Label) ], t.prototype, "atkLabel", void 0), a([ y(cc.Label) ], t.prototype, "speLabel", void 0), 
    a([ y(cc.Label) ], t.prototype, "ranLabel", void 0), a([ y(cc.Label) ], t.prototype, "criLabel", void 0), 
    a([ y(cc.Label) ], t.prototype, "movLabel", void 0), a([ y(cc.Label) ], t.prototype, "numLabel", void 0), 
    a([ y(cc.Node) ], t.prototype, "up", void 0), a([ y(cc.Node) ], t.prototype, "down", void 0), 
    a([ y(cc.Label) ], t.prototype, "rankLabel", void 0), a([ y(c.default) ], t.prototype, "hpView", void 0), 
    a([ m ], t);
}(r.default);

n.default = v;